import requests
from util.get_fonts import get_font_maps
font_maps = get_font_maps('./static/font/file')

# def parse_fild(value):
#     s = value
#     result = ""
#     for item in s.split("&")[1:]:
#         result += font_maps[item.replace("#", "0")]
#
#     return result

def parse_fild(value):
    s = value
    result = ""
    for item in s.split("&")[1:]:
        # 1. 把 # 替换成 0
        hex_str = item.replace("#", "0")
        # 2. 十六进制字符串 → int → chr
        ch = chr(int(hex_str, 16))
        # 3. 查表
        result += font_maps.get(ch, '?')   # 找不到就给个问号
    return result

res = requests.get('https://www.shixiseng.com/app/interns/search/v2?build_time=1763366855597&page=1&type=intern&keyword=&area=&months=&days=&degree=&official=&enterprise=&salary=-0&publishTime=&sortType=&city=%E5%85%A8%E5%9B%BD&internExtend=', headers={
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36'
})

for item in res.json()['msg']['data']:
    print(item['cname'], item['industry'], parse_fild(item['maxsal']), parse_fild(item['minsal']))